package com.wipz.eoa.iphone.user;

import java.util.HashMap;
import java.util.Map;

import com.toft.core2.UserInfo;
import com.toft.utils.Md5;
import com.wipz.eoa.iphone.BaseAction;
import com.wipz.eoa.iphone.IBaseService;
/**
 * 
 * @author Biqing Zeng
 * @date 2012-2-8 下午04:48:49
 */
public class UserInfoAction extends BaseAction {

	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;

	private IBaseService baseService;
	private LoginOperate loginOperate;
	
	public void setLoginOperate(LoginOperate loginOperate) {
		this.loginOperate = loginOperate;
	}

	private Map login;
	
	public Map getLogin() {
		return login;
	}

	public void setLogin(Map login) {
		this.login = login;
	}

	public void setBaseService(IBaseService baseService) {
		this.baseService = baseService;
	}

	/**
	 * 用户登录
	 * @return 
	 * 2012-2-8 下午06:06:12
	 */
	public String login(){
		String userName = this.getRequest().getParameter("userName");
		String password = this.getRequest().getParameter("password");
			password = Md5.md5(password);
		Map<String,String> map = new HashMap<String,String>();
		map.put("userName", userName);
		map.put("password", password);
		Map mapUserCode =  (Map) baseService.queryOne("user.query", map);
		if(null == mapUserCode || mapUserCode.isEmpty()) {
			login = new HashMap();
			login.put("CODE", "");
			return SUCCESS;
		}
		UserInfo userInfo = new UserInfo();
		String COMMITERCODE = (String) mapUserCode.get("CODE");
		Map mapUuitId =  (Map) baseService.queryOne("user.queryAll", COMMITERCODE);
		userInfo.setOrgId((String) mapUuitId.get("ORGID"));
		userInfo.setUserId((String) mapUuitId.get("ID"));
		login = loginOperate.getMenus2(userInfo.getUserId(),userInfo.getOrgId(),mapUserCode);
	//	login = mapUserCode;
		return SUCCESS;
	}
	
}
